/***********************************************************************
 * Module:  CourseCreerIhmImpl.java
 * Author:  29004847
 * Purpose: Defines the Class CourseCreerIhmImpl
 ***********************************************************************/

package chrono_views;

import chrono_controller.*;

import java.awt.EventQueue;
import java.util.*;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.BorderLayout;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JTextPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.BoxLayout;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import java.awt.SystemColor;
import javax.swing.SwingConstants;
import javax.swing.JList;
import java.awt.Color;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;

public class CourseCreerIhmImpl extends JFrame implements Ihm {
	private Controller controller_;
	private JPanel contentPane;
	private JTextField nomCourse;
	private JTextField heureDepart;
	private JTextField dureeTotMaxPilote;
	private JTextField dureeConsecMaxPilote;
	private JTextField nbToursMaxPilote;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CourseCreerIhmImpl frame = new CourseCreerIhmImpl();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public CourseCreerIhmImpl() {
		setTitle("Cr\u00E9ation ou modification de course/essai");
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 575, 552);
		contentPane = new JPanel();
		contentPane.setBackground(UIManager.getColor("inactiveCaption"));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		nomCourse = new JTextField();
		nomCourse.setColumns(10);
		
		JTextPane txtpnNomCourse = new JTextPane();
		txtpnNomCourse.setBackground(UIManager.getColor("inactiveCaption"));
		txtpnNomCourse.setText("Nom course");
		
		JRadioButton rdbtnEssai = new JRadioButton("essai");
		rdbtnEssai.setBackground(UIManager.getColor("inactiveCaption"));
		rdbtnEssai.setSelected(true);
		rdbtnEssai.setHorizontalAlignment(SwingConstants.LEFT);
		
		JRadioButton rdbtnCourse = new JRadioButton("course");
		rdbtnCourse.setBackground(UIManager.getColor("inactiveCaption"));
		rdbtnCourse.setHorizontalAlignment(SwingConstants.LEFT);
		
		JCheckBox chckbxDpartAutomatique = new JCheckBox("D\u00E9part automatique");
		chckbxDpartAutomatique.setBackground(UIManager.getColor("inactiveCaption"));
		
		JTextPane txtpnHeureDpart = new JTextPane();
		txtpnHeureDpart.setText("Heure d\u00E9part");
		txtpnHeureDpart.setBackground(UIManager.getColor("inactiveCaption"));
		
		heureDepart = new JTextField();
		heureDepart.setColumns(10);
		
		JTextPane txtpnDureTotaleMax = new JTextPane();
		txtpnDureTotaleMax.setText("Dur\u00E9e totale max pilote");
		txtpnDureTotaleMax.setBackground(UIManager.getColor("inactiveCaption"));
		
		dureeTotMaxPilote = new JTextField();
		dureeTotMaxPilote.setColumns(10);
		
		JTextPane txtpnDureConscutiveMax = new JTextPane();
		txtpnDureConscutiveMax.setText("Dur\u00E9e cons\u00E9cutive max pilote");
		txtpnDureConscutiveMax.setBackground(UIManager.getColor("inactiveCaption"));
		
		dureeConsecMaxPilote = new JTextField();
		dureeConsecMaxPilote.setColumns(10);
		
		JTextPane txtpnNombreToursMax = new JTextPane();
		txtpnNombreToursMax.setText("Nombre tours max pilote");
		txtpnNombreToursMax.setBackground(UIManager.getColor("inactiveCaption"));
		
		nbToursMaxPilote = new JTextField();
		nbToursMaxPilote.setColumns(10);
		
		JList list_voitures_of_course = new JList();
		list_voitures_of_course.setBorder(new LineBorder(new Color(0, 0, 0)));
		
		JList list_allvoitures = new JList();
		list_allvoitures.setBorder(new LineBorder(new Color(0, 0, 0)));
		
		JButton btnNewButton = new JButton("Ajouter voiture");
		btnNewButton.setBackground(UIManager.getColor("inactiveCaption"));
		
		JButton btnRetirerVoiture = new JButton("Retirer voiture");
		btnRetirerVoiture.setBackground(UIManager.getColor("inactiveCaption"));
		
		JButton btnCreerVoiture = new JButton("Cr\u00E9er voiture");
		btnCreerVoiture.setBackground(UIManager.getColor("inactiveCaption"));
		
		JTextArea commentaires = new JTextArea();
		
		JLabel lblCommentaires = new JLabel("Commentaires : ");
		
		JButton btnSauvegarder = new JButton("Sauvegarder");
		btnSauvegarder.setBackground(UIManager.getColor("inactiveCaption"));
		
		JButton btnAnnuler = new JButton("Annuler");
		btnAnnuler.setBackground(UIManager.getColor("inactiveCaption"));
		
		JLabel lblNewLabel = new JLabel("Voitures rattach\u00E9es \u00E0 la course");
		
		JLabel lblListeDeToutes = new JLabel("Liste de toutes les voitures");
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(25)
							.addComponent(rdbtnEssai)
							.addGap(38)
							.addComponent(rdbtnCourse, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(25)
							.addComponent(lblCommentaires))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(185)
							.addComponent(btnSauvegarder)
							.addGap(6)
							.addComponent(btnAnnuler, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE))
						.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
								.addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup()
									.addGap(25)
									.addComponent(commentaires, GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE))
								.addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup()
									.addGap(25)
									.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
										.addComponent(btnCreerVoiture)
										.addGroup(gl_contentPane.createSequentialGroup()
											.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
												.addComponent(lblNewLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
												.addComponent(list_voitures_of_course, GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
											.addPreferredGap(ComponentPlacement.UNRELATED)
											.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
												.addComponent(btnNewButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
												.addComponent(btnRetirerVoiture, GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
											.addPreferredGap(ComponentPlacement.UNRELATED)
											.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
												.addComponent(lblListeDeToutes, GroupLayout.PREFERRED_SIZE, 166, GroupLayout.PREFERRED_SIZE)
												.addComponent(list_allvoitures, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)))))
								.addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup()
									.addGap(211)
									.addComponent(txtpnDureConscutiveMax, GroupLayout.PREFERRED_SIZE, 199, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addComponent(dureeConsecMaxPilote, GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
								.addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup()
									.addGap(25)
									.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_contentPane.createSequentialGroup()
											.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
												.addGroup(gl_contentPane.createSequentialGroup()
													.addComponent(txtpnNombreToursMax, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
													.addGap(6)
													.addComponent(nbToursMaxPilote, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE))
												.addComponent(chckbxDpartAutomatique))
											.addPreferredGap(ComponentPlacement.UNRELATED)
											.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
												.addComponent(txtpnHeureDpart, GroupLayout.PREFERRED_SIZE, 182, GroupLayout.PREFERRED_SIZE)
												.addComponent(txtpnDureTotaleMax, GroupLayout.PREFERRED_SIZE, 198, GroupLayout.PREFERRED_SIZE))
											.addPreferredGap(ComponentPlacement.UNRELATED)
											.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
												.addComponent(heureDepart, GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
												.addComponent(dureeTotMaxPilote, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)))
										.addGroup(gl_contentPane.createSequentialGroup()
											.addComponent(txtpnNomCourse, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
											.addComponent(nomCourse, GroupLayout.PREFERRED_SIZE, 385, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)))))
							.addGap(125)))
					.addGap(4))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(11)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(txtpnNomCourse, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(nomCourse, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(7)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(rdbtnEssai)
						.addComponent(rdbtnCourse))
					.addGap(3)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(chckbxDpartAutomatique)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(4)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(heureDepart, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(txtpnHeureDpart, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addGap(6)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(txtpnNombreToursMax, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(nbToursMaxPilote, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(dureeTotMaxPilote, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(txtpnDureTotaleMax, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(dureeConsecMaxPilote, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(txtpnDureConscutiveMax, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(53)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblListeDeToutes)
						.addComponent(lblNewLabel))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(10)
							.addComponent(btnNewButton)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(btnRetirerVoiture))
						.addComponent(list_allvoitures, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE)
						.addComponent(list_voitures_of_course, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(btnCreerVoiture)
					.addGap(26)
					.addComponent(lblCommentaires)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(commentaires, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
					.addGap(22)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(btnSauvegarder)
						.addComponent(btnAnnuler))
					.addGap(11))
		);
		contentPane.setLayout(gl_contentPane);
	}
}